<!doctype html>
<html class="noDragging" lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta name="renderer" content="webkit" />
	    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width,height=device-height">
        <title>CSGO</title>
        <link href="favicon.ico" rel="shortcut icon">
	    <script src="./js/common/axios.min.js"></script>
        <script src="./js/common/vue.js"></script>
        <script src="./js/common/vue-resource.js"></script>
        <link rel="stylesheet" href="css/common/swiper.css">
        <link rel="stylesheet" href="css/common/base.css">
        <link rel="stylesheet" href="css/common/media.css">
        <link rel="stylesheet" href="css/index.css">
        <style type="text/css">
            [v-cloak]{
              display: none;
            }
            .tp .item{
                flex: 1;
            }
        </style>
    </head>
    <body>

        <div id="contn">
           <div class="tp flex" @click="capture">
                <div class="item">
                    <div class="t hvc">
                        <p>{{ttl}}</p>
                    </div>
                </div>
           </div>
           <main>
                <div :class="['filter',show?'active':'']">
                    <img src="img/filter.png" @click="hdlShow">
                    <div class="opt">
                        <p :class="i == optInd?'active':''" v-for="(item,i) in opt" @click="filter(i)">{{item}}</p>
                    </div>
                </div>
                <div class="list flex">
                    <div :class="['item','id' + item.id,item.repeate?'have':'']" v-for="(item,i) in list">
                        <div class="mid">
                            <img class="hvcContn" :src='"img/pro/" + item.url + ".png"' v-if="item.url">
                            <div class="dateSpeed flex">{{item.boughtDate}} <p class="speed">{{item.speed}}</p></div>
                        </div>
                        <p class="name">{{item.name?item.name + ' ' + item.url:item.url}}</p>
                        <div class="flex price">
                            <p class="bf">{{item.boughtPrice}}</p>
                            <p :class="['compare',!item.up?'down':'']">{{item.earn}}</p>
                        </div>
                        <div class="now price">
                            <p class=''>{{item.price}}</p>
                        </div>
                    </div>
                </div>
           </main>
        </div>
               
        <script src="js/common/swiper.js"></script>
        <script src="js/common/jquery.js"></script>
        <script src="js/common/dataUrl.js"></script>
        <script src="./js/index.js"></script>
        <script src="js/html2canvas.js"></script>
        <script>
            
            var getProInt = null;
            var contn = new Vue({
                el:'#contn',
                data:{
                    uuToken:'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwMTY5ZjQ3ODUwMWQ0YTQ2YmM5ZDI2MDk0MDk5MWY5MiIsIm5hbWVpZCI6IjE1MDcwMTkiLCJJZCI6IjE1MDcwMTkiLCJ1bmlxdWVfbmFtZSI6IndlYXNua2lpIiwiTmFtZSI6IndlYXNua2lpIiwibmJmIjoxNzA3MDk2NzYxLCJleHAiOjE3MDc5NjA3NjEsImlzcyI6InlvdXBpbjg5OC5jb20iLCJhdWQiOiJ1c2VyIn0.ZmcV5NaE53aZfmDsnhIu6pRsubop7UHD5SpYBtFD8JA',
                    uuUserId:'1507019',
                    showInp:false,
                    proNums:0,
                    page:0,
                    finish:false,
                    relax:false,
                    relaxCount:0,
                    hasPosted:0,
                    opt:['↓ 涨价','↑ 涨价'],
                    optInd:0,
                    list:[
                        // {name:'',soldPrice:0,up:true,earn:0,boughtPrice:13666,repeate:true,url:''},
                        {name:'.25无损',soldPrice:16500,up:true,earn:0,boughtPrice:15600,repeate:true,url:'薄荷'},
                        {name:'',soldPrice:9380,up:true,earn:0,boughtPrice:9260,repeate:true,url:'蝴蝶 自动化'},
                        {name:'.28',soldPrice:12134,up:true,earn:0,boughtPrice:9775,repeate:true,url:'薄荷'},
                        {name:'.27',soldPrice:13500,up:true,earn:0,boughtPrice:12600,repeate:true,url:'薄荷'},
                        {name:'',soldPrice:3340,up:true,earn:0,boughtPrice:5050,repeate:true,url:'大理石'},
                        {name:'皇冠 电子蜂巢',soldPrice:1100,up:true,earn:0,boughtPrice:1455,repeate:true,url:''},
                        {name:'',soldPrice:10700,up:true,earn:0,boughtPrice:9999,repeate:true,url:'蝴蝶 屠夫'},
                        {name:'',soldPrice:2740,up:true,earn:0,boughtPrice:2399,repeate:true,url:'短剑 淬火'},
                        {name:'',soldPrice:10400,up:true,earn:0,boughtPrice:9750,repeate:true,url:'蝴蝶 屠夫'},
                        {name:'',soldPrice:7799,up:true,earn:0,boughtPrice:8225,repeate:true,url:'弹弓 久经'},
                        {name:'',soldPrice:3380,up:true,earn:0,boughtPrice:5099,repeate:true,url:'大理石'},
                        {name:'',soldPrice:4700,up:true,earn:0,boughtPrice:3400,repeate:true,url:'爪子 人工'},
                        {name:'',soldPrice:3395,up:true,earn:0,boughtPrice:3301,repeate:true,url:'刺刀 自动化'},
                        {name:'',soldPrice:3799,up:true,earn:0,boughtPrice:3300,repeate:true,url:'弹弓 破损'},
                        {name:'',soldPrice:9799,up:true,earn:0,boughtPrice:9561,repeate:true,url:'爪子 多普勒'},
                        {name:'',soldPrice:3950,up:true,earn:0,boughtPrice:3500,repeate:true,url:'骷髅 淬火'},
                        {name:'.28',soldPrice:11078,up:true,earn:0,boughtPrice:9250,repeate:true,url:'薄荷'},
                        {name:'',soldPrice:18699,up:true,earn:0,boughtPrice:18999,repeate:true,url:'蝴蝶 多普勒'},
                        {name:'',soldPrice:3400,up:true,earn:0,boughtPrice:5030,repeate:true,url:'大理石'},
                        {name:'',soldPrice:14215,up:true,earn:0,boughtPrice:14199,repeate:true,url:'超导体'},
                        {name:'非计数器屁股位titan',soldPrice:604,up:true,earn:0,boughtPrice:566,repeate:true,url:''},
                        {name:'计数器倒数第2位置titan',soldPrice:860,up:true,earn:0,boughtPrice:765,repeate:true,url:''},
                        {name:'',soldPrice:2443.68,up:true,earn:0,boughtPrice:2270,repeate:true,ifBuff:true,url:'骷髅 人工'},
                        {name:'3连Faze + Nip',soldPrice:130,up:true,earn:0,boughtPrice:165,repeate:true,ifBuff:true,url:''},
                        {name:'4连Faze(一刮)',soldPrice:150,up:true,earn:0,boughtPrice:145,repeate:true,ifBuff:true,url:''},
                        {name:'4连Faze',soldPrice:150,up:true,earn:0,boughtPrice:167,repeate:true,ifBuff:true,url:''},
                        {name:'4连粉Faze 选手',soldPrice:150,up:true,earn:0,boughtPrice:100,repeate:true,ifBuff:true,url:''},
                        {name:'',soldPrice:895,up:true,earn:0,boughtPrice:1010,repeate:true,ifBuff:true,url:'AWP二西'},
                        {name:'',soldPrice:888,up:true,earn:0,boughtPrice:1010,repeate:true,url:'AWP二西'},
                        {name:'',soldPrice:129.3,up:true,earn:0,boughtPrice:124.8,repeate:true,ifBuff:true,url:'拆弹倒计时 闪亮'},
                        {name:'',soldPrice:468,up:true,earn:0,boughtPrice:450,repeate:true,url:'沙鹰 印花集'},
                        {name:'',soldPrice:389,up:true,earn:0,boughtPrice:368,repeate:true,url:'usp 印花集'},
                        {name:'',soldPrice:358,up:true,earn:0,boughtPrice:360,repeate:true,url:'usp 印花集'},
                        {name:'',soldPrice:1284,up:true,earn:0,boughtPrice:1290,repeate:true,url:'A1 印花集'},
                        {name:'',soldPrice:1284,up:true,earn:0,boughtPrice:1290,repeate:true,url:'A1 印花集'},
                        {name:'',soldPrice:137,up:true,earn:0,boughtPrice:125,repeate:true,ifBuff:true,url:'A4 弹雨'},
                        {name:'',soldPrice:1650,up:true,earn:0,boughtPrice:1600,repeate:true,ifBuff:true,url:'熊刀 淬火'},
                        {name:'',soldPrice:4675,up:true,earn:0,boughtPrice:3150,repeate:true,ifBuff:true,url:'爪子 自由'},
                        {name:'',soldPrice:1540,up:true,earn:0,boughtPrice:870,repeate:true,ifBuff:true,url:'短剑 都市'},
                        {name:'',soldPrice:1380,up:true,earn:0,boughtPrice:800,repeate:true,ifBuff:true,url:'熊刀 大马士'},
                        {name:'',soldPrice:1210,up:true,earn:0,boughtPrice:792,repeate:true,ifBuff:true,url:'流浪 都市'},
                        {name:'',soldPrice:1120,up:true,earn:0,boughtPrice:1000,repeate:true,ifBuff:true,url:'流浪 北方'},
                        {name:'',soldPrice:1740,up:true,earn:0,boughtPrice:1110,repeate:true,ifBuff:true,url:'穿肠 传说'},
                        {name:'',soldPrice:755,up:true,earn:0,boughtPrice:529.12,repeate:true,ifBuff:true,url:'猎杀 生锈'},
                        {name:'',soldPrice:740,up:true,earn:0,boughtPrice:529.12,repeate:true,url:'猎杀 生锈'},
                        {name:'',soldPrice:1019,up:true,earn:0,boughtPrice:951,repeate:true,ifBuff:true,url:'裹手 皮革'},
                        {name:'',soldPrice:3300,up:true,earn:0,boughtPrice:3150,repeate:true,url:'锯齿 表面'},
                        {name:'',soldPrice:2110,up:true,earn:0,boughtPrice:1501,repeate:true,url:'流浪 蓝钢'},
                        {name:'',soldPrice:3630,up:true,earn:0,boughtPrice:3050,repeate:true,url:'刺刀 自动化'},
                        {name:'',soldPrice:2905,up:true,earn:0,boughtPrice:1758,repeate:true,url:'折叠 自动化'},
                        {name:'',soldPrice:3410,up:true,earn:0,boughtPrice:2399,repeate:true,url:'流浪 屠夫'},
                        {name:'',soldPrice:3280,up:true,earn:0,boughtPrice:2800,repeate:true,url:'双栖'},
                        {name:'',soldPrice:1629,up:true,earn:0,boughtPrice:1015,repeate:true,url:'折叠 黑色'},
                        {name:'',soldPrice:1433,up:true,earn:0,boughtPrice:920,repeate:true,url:'流浪 夜色'},
                        {name:'',soldPrice:1216,up:true,earn:0,boughtPrice:750,repeate:true,url:'弯刀 大马士'},
                        {name:'',soldPrice:2210,up:true,earn:0,boughtPrice:1280,repeate:true,url:'流浪 人工'},
                        {name:'',soldPrice:4000,up:true,earn:0,boughtPrice:3531,repeate:true,url:'M9 大马士'},
                        {name:'',soldPrice:830,up:true,earn:0,boughtPrice:495,repeate:true,url:'穿肠 黑色'},
                        {name:'',soldPrice:1800,up:true,earn:0,boughtPrice:1635,repeate:true,url:'刺刀 紫罗兰'},
                        {name:'',soldPrice:1585,up:true,earn:0,boughtPrice:960,repeate:true,url:'熊刀 紫罗兰'},
                        {name:'',soldPrice:1128,up:true,earn:0,boughtPrice:960,repeate:true,url:'流浪 网格'},
                        {name:'',soldPrice:2370,up:true,earn:0,boughtPrice:1610,repeate:true,url:'骷髅 都市'},
                        {name:'',soldPrice:5018.89,up:true,earn:0,boughtPrice:5338,repeate:true,url:'蝴蝶 噩梦'},
                        {name:'',soldPrice:1440,up:true,earn:0,boughtPrice:880,repeate:true,url:'短剑 生锈'},
                        {name:'',soldPrice:1275,up:true,earn:0,boughtPrice:780,repeate:true,url:'折叠 生锈'},
                        {name:'',soldPrice:3040,up:true,earn:0,boughtPrice:3001,repeate:true,url:'刺刀 淬火'},
                        {name:'',soldPrice:1560,up:true,earn:0,boughtPrice:914.9,repeate:true,url:'折叠 自由'},
                        {name:'',soldPrice:1905,up:true,earn:0,boughtPrice:1711,repeate:true,url:'短剑 人工'},
                        {name:'',soldPrice:850,up:true,earn:0,boughtPrice:507,repeate:true,url:'熊刀 生锈'},
                        {name:'',soldPrice:1850,up:true,earn:0,boughtPrice:1450,repeate:true,url:'骷髅 枯焦'},
                        {name:'',soldPrice:1090,up:true,earn:0,boughtPrice:999,repeate:true,url:'流浪 DDPAT'},
                        {name:'',soldPrice:1500,up:true,earn:0,boughtPrice:880,repeate:true,url:'折叠 大马士'},
                        {name:'',soldPrice:1585,up:true,earn:0,boughtPrice:1015,repeate:true,url:'折叠 澄澈'},
                        {name:'',soldPrice:971,up:true,earn:0,boughtPrice:890,repeate:true,url:'流浪 枯焦'},
                        {name:'',soldPrice:1355,up:true,earn:0,boughtPrice:885,repeate:true,url:'短剑 夜色'},
                        {name:'',soldPrice:4035,up:true,earn:0,boughtPrice:2650,repeate:true,url:'爪子 生锈'},
                        {name:'',soldPrice:1450,up:true,earn:0,boughtPrice:1412,repeate:true,url:'裹手 屠夫'},
                        {name:'',soldPrice:1963,up:true,earn:0,boughtPrice:1934,repeate:true,url:'夜行衣'},
                        {name:'',soldPrice:2980,up:true,earn:0,boughtPrice:2900,repeate:true,url:'裹手 钴蓝'},
                        {name:'',soldPrice:675,up:true,earn:0,boughtPrice:649,repeate:true,url:'熊刀 夜色'},
                        {name:'',soldPrice:770,up:true,earn:0,boughtPrice:720,repeate:true,url:'熊刀 人工'},
                    ],
                    show:false,
                    ttl:0
                },
                methods:{
                       
                },
                created(){
                    var This = this;
                    var list = newObj(this.list);
                    var ttl = 0;
                    list.forEach(function(item){
                        var soldPrice = item.soldPrice;
                        item.ifBuff && (soldPrice *= .975)
                        item.earn = (soldPrice - item.boughtPrice).toFixed(2);
                        ttl += Number(item.earn);
                        item.up = item.earn < 0?false:true;
                    })
                    this.ttl = (ttl * .99).toFixed(2);
                    this.list = list.sort(this.compare('earn'));
                    return false;
                    getProInt = setInterval(function(){
                        if(This.relax){
                            This.relaxCount++;
                            This.relaxCount == 3 && (This.relax = false,This.relaxCount = 0);
                            return false;
                        }
                        // for(var n = This.page * 10;n < (This.page + 1) * 10;n++){
                        //     //This.list.length
                        //     This.getPro(This.list[n].id);
                        // }
                        
                            This.getPro(This.list[This.hasPosted].id,This.list[This.hasPosted].ml,This.list[This.hasPosted].mlLvl);
                            This.hasPosted++;
                            if(This.hasPosted % 10 == 0){
                                This.relax = true;
                            }
                            if(This.hasPosted >= This.list.length){
                                clearInterval(getProInt);
                                getProInt = null;
                                console.log(This.list);
                                
                                
                                setTimeout(function(){
                                    var repeateAry = getMatchedItm(This.list,true,'repeate');
                                    var oriList = newObj(This.list);
                                    for(var r = 0;r < oriList.length;r++){
                                        if(oriList[r].repeate == false){
                                            var MatchedItem = getSpecifyItem(repeateAry,oriList[r].id,'id')
                                            console.log(MatchedItem);
                                            oriList[r].price = MatchedItem.price;
                                            oriList[r].name = MatchedItem.name;
                                            oriList[r].gap = (MatchedItem.price - oriList[r].boughtPrice).toFixed(2);
                                            console.log(MatchedItem.price , oriList[r].boughtPrice);
                                            oriList[r].speed = (oriList[r].gap / parseInt((new Date() - new Date(oriList[r].boughtDate)) / 3600 /24 / 1000)).toFixed(1);
                                            oriList[r].up = oriList[r].gap > 0?true:false;
                                            oriList[r].url1 = MatchedItem.url1;
                                        }
                                     
                                    }
                                    console.log(oriList);
                                    // $('img')[1].setAttribute('src',repeateAry[0].url1);
                                    This.list = oriList;
                                    This.filter(This.optInd);
                                    var ttl = [
                                        {name:'购入价',num:0},
                                        {name:'当前价',num:0},
                                    ];
                                    for(var t = 0;t < oriList.length;t++){
                                        ttl[1].num += Number(oriList[t].price);
                                        ttl[0].num += Number(oriList[t].boughtPrice);
                                    }
                                    (ttl[0].num).toFixed(2);
                                    (ttl[1].num).toFixed(2);
                                    This.ttl = ttl;
                                },1000)
                                
                            }
                        
                        
                    },200)
                    //This.getPro1();
                },
                mounted:function(){
                    ifMounted = true;
                },
                methods:{
                    hdlShow(){
                        this.show = !this.show;
                    },
                    filter(ind){
                        this.optInd = ind;
                        if(ind == 0){
                            this.list.sort(this.compare('gap'));
                        }else if(ind == 1){
                            this.list.sort(this.compare('gap',1));
                        }else if(ind == 2){
                            this.list.sort(this.compare('speed'));
                        }else if(ind == 3){
                            this.list.sort(this.compare('speed',1));
                        }
                    },
                    getMatchedIndex(thing,val,keyName,){
                        if(typeof(thing) == 'object'){
                            for(var n = 0;n < thing.length;n++){
                                if(thing[n][keyName] == val){
                                    return n;
                                }
                            }
                        }else{
                            return (thing.indexOf(val));
                        }
                    },
                    ifCanLogin(){
                        console.log(1);
                        axios.get('https://api.youpin898.com/api/user/Account/GetUserInfo',{
                            headers:{
                                Authorization: uuToken
                            }
                        }).then((res) => {
                            //console.log(res);
                        })
                    },
                    getPro(id,ifMl,mlLvl){
                        var This = this;
                        var obj = {
                            templateId:id,
                            pageSize:1,
                            pageIndex:1,
                            sortType:1,
                            listSortType:1,
                            userId:this.uuUserId,
                        }
                        if(ifMl){
                            obj.maxAbrade = this.rangeAry[mlLvl - 1].max;
                            obj.minAbrade = this.rangeAry[mlLvl - 1].min;
                        }
                        if(getSpecifyVal(this.list,id,'id','keyWords')){
                            obj.keyWords = getSpecifyVal(this.list,id,'id','keyWords');
                        }
                        axios.post('https://api.youpin898.com/api/homepage/v2/es/commodity/GetCsGoPagedList',obj,{
                            headers:{
                                Authorization: uuToken,
                            }
                        }).then((res) => {
                            console.log(res.data.Data.CommodityList[0].TemplateId,res.data.Data.CommodityList[0].CommodityName);
                            this.proNums++;
                            var data = res.data.Data.CommodityList[0];
                            var list = newObj(this.list);
                            var ind = this.getMatchedIndex(list,data.TemplateId,'id');
                            list[ind].url = data.IconUrl;
                            main(data.IconUrl, function(base64){
                                var list = JSON.parse(JSON.stringify(This.list));
                                list[ind].url1 = base64;
                                This.list = list;
                            });
                            list[ind].name = data.CommodityName;
                            list[ind].price = Number(data.Price);
                            list[ind].gap = (data.Price - list[ind].boughtPrice).toFixed(2);
                            list[ind].speed = (list[ind].gap / parseInt((new Date() - new Date(list[ind].boughtDate)) / 3600 /24 / 1000)).toFixed(1);
                            list[ind].up = list[ind].gap > 0?true:false;
                            var ttl = this.ttl;
                            ttl[1].num += Number(data.Price);
                            ttl[0].num += Number(list[ind].boughtPrice);
                            (ttl[0].num).toFixed(2);
                            (ttl[1].num).toFixed(2);
                            this.ttl = ttl;
                            this.list = list;
                            
                        })
                    },
                    getPro1(){
                        var obj = {
                            templateId:'52763',
                            pageSize:1,
                            pageIndex:1,
                            sortType:1,
                            listSortType:1,
                            userId:this.uuUserId,
                        }
                        axios.post('https://api.youpin898.com/api/homepage/v2/es/commodity/GetCsGoPagedList',obj,{
                            headers:{
                                Authorization: uuToken,
                            }
                        }).then((res) => {
                            console.log(res);

                            //res.data.data.CommodityList[0]
                        })
                    },
                    compare (property,ifUp) {
                        return function (a, b) {
                            var value1 = a[property];
                            var value2 = b[property];
                            if(ifUp){
                                return value1 - value2;
                            }else{
                                return value2 - value1;
                            }
                            
                        }
                    },
                    capture(){
                        console.log(this.list);
                        // this.list.forEach(function(item,i){
                        //     $('.list .item .mid img').eq(i).attr('src',item.url1);
                        // })
                        renderPdf('sold');
                    }
                }
            })
            
        </script>   
        <script src="js/index.js"></script>
    </body>
</html>